package com.hangxintong.common.base.entity;

import com.fasterxml.jackson.annotation.JsonFormat;
import com.fasterxml.jackson.annotation.JsonIgnoreProperties;
import lombok.Data;
import lombok.NoArgsConstructor;
import lombok.ToString;
import org.hibernate.annotations.Where;
import org.springframework.data.annotation.CreatedDate;
import org.springframework.data.annotation.LastModifiedDate;
import org.springframework.data.jpa.domain.support.AuditingEntityListener;

import javax.persistence.*;

import java.math.BigDecimal;
import java.util.Date;
import java.util.List;

/**
 * 协会信息表
 *
 * @author mxf 2019-15-25
 */
@Entity
@Data
@Where(clause = "is_delete=false")
@JsonIgnoreProperties({"hibernateLazyInitializer", "handler"})
@EntityListeners(AuditingEntityListener.class)
@NoArgsConstructor
public class LmAssociation {

    @Id
    private  Long assocId;
    private  String assocName;
    private  String assocCreditCode;
    private  String assocLicense;
    private  String assocAddress;
    private  String assocLogo;
    private String assocAuthImg;
    private String assocPasswd;
    private Long assocCountryNum;
    private Long assocCityNum;
    private Long assocProvinceNum;
    private int isRecommend;
    private Long assocStar;
    private boolean isDelete;
    private Long assocIndCateId;
    //分类名称
    private String assocIndCateName = "";
    //业务范围
    private String businessScope = "";
    @CreatedDate
    @JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss")
    private Date createTime;

    @LastModifiedDate
    @JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss")
    private Date updateTime;

    @JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss")
    private Date deleteTime;

    private short assocStatus;
    private String assocAuditOpinion;
    private String expertRemark;
    private Long assocCheckUser;

    @JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss")
    private Date checkTime;

    private Long assocCreateId;
    private Long assocParentId;
    private Short assocAreaLevel;

    @JsonFormat(pattern = "yyyy-MM-dd")
    private Date assocSetTime;

    private String belongOrder;
    private String uniqueCode;
    private BigDecimal total;
    private String starTime = "";
    private String endTime;
    private String regPrice;
    private String authority;
    //地域code
    private String regionCode;
    private String region;
    private String businessCompetentUnit;
    private String legalPerson;

    // 联系人信息
    private String mobile;
    private String realName;
    private String job;
    private String email;
    //网址
    private String webUrl = "";
    //使命
    private String mission = "";
    //简介
    private String brief = "";
    //简介
    private String ruleTitle = "";
    //章程
    private String ruleContent = "";
    //统计协会人员
    @Transient
    private Integer assocPersonNum = 0;
    //    @OneToOne(fetch = FetchType.LAZY)
//    @JoinColumn(name = "assocId",referencedColumnName = "companyId",insertable=false,updatable=false)
//    @Transient
//    private LmAssociationInfo info;

//    @OneToOne(fetch = FetchType.LAZY)
//    @JoinColumn(name = "assocProvinceNum", referencedColumnName = "areaCode", insertable = false, updatable = false)
//    @ToString.Exclude
//    private LmToolsCity toolsCity;

    @OneToMany(cascade = {CascadeType.REFRESH})
    @JoinColumn(name = "assocParentId")
    @ToString.Exclude
    private List<LmAssociation> assocParent;


    @Transient
    private int memberCompanyNums;
    @Transient
    private int memberPersonNums;

    private String background;
}
